<?php

/**
 * This is the model class for table "sps_adcodes_sql".
 *
 * The followings are the available columns in table 'sps_adcodes_sql':
 * @property integer $Kundennummer
 * @property integer $Terminnummer_Archiv
 * @property integer $Kontaktnummer
 * @property integer $Codes_Gruppe
 * @property integer $Code
 * @property string $Verbindungsart
 * @property string $Datum
 * @property integer $Anzahl1
 * @property integer $Anzahl_2
 * @property integer $Anzahl_3
 * @property integer $Anzahl_4
 * @property double $Betrag
 * @property string $VerbindungsTabelle
 * @property string $VerbindungsKey
 * @property string $Bitmap_Verbindung
 * @property string $Verbindungsfilekey
 * @property string $Bezeichnung
 */
class MemberCode extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MemberCode the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sps_adcodes_sql';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('Bezeichnung', 'required'),
			array('Kundennummer, Terminnummer_Archiv, Kontaktnummer, Codes_Gruppe, Code, Anzahl1, Anzahl_2, Anzahl_3, Anzahl_4', 'numerical', 'integerOnly'=>true),
			array('Betrag', 'numerical'),
			array('Verbindungsart', 'length', 'max'=>1),
			array('Datum, VerbindungsTabelle', 'length', 'max'=>10),
			array('VerbindungsKey, Verbindungsfilekey', 'length', 'max'=>30),
			array('Bitmap_Verbindung', 'length', 'max'=>80),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('Kundennummer, Terminnummer_Archiv, Kontaktnummer, Codes_Gruppe, Code, Verbindungsart, Datum, Anzahl1, Anzahl_2, Anzahl_3, Anzahl_4, Betrag, VerbindungsTabelle, VerbindungsKey, Bitmap_Verbindung, Verbindungsfilekey, Bezeichnung', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'code' => array(self::BELONGS_TO, 'Code', array('Haupt_Code' => 'Codes_Gruppe', 'Code' => 'Code'), 'joinType' => 'INNER JOIN'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Kundennummer' => 'Kundennummer',
			'Terminnummer_Archiv' => 'Terminnummer Archiv',
			'Kontaktnummer' => 'Kontaktnummer',
			'Codes_Gruppe' => 'Codes Gruppe',
			'Code' => 'Code',
			'Verbindungsart' => 'Verbindungsart',
			'Datum' => 'Datum',
			'Anzahl1' => 'Anzahl1',
			'Anzahl_2' => 'Anzahl 2',
			'Anzahl_3' => 'Anzahl 3',
			'Anzahl_4' => 'Anzahl 4',
			'Betrag' => 'Betrag',
			'VerbindungsTabelle' => 'Verbindungs Tabelle',
			'VerbindungsKey' => 'Verbindungs Key',
			'Bitmap_Verbindung' => 'Bitmap Verbindung',
			'Verbindungsfilekey' => 'Verbindungsfilekey',
			'Bezeichnung' => 'Bezeichnung',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Kundennummer',$this->Kundennummer);
		$criteria->compare('Terminnummer_Archiv',$this->Terminnummer_Archiv);
		$criteria->compare('Kontaktnummer',$this->Kontaktnummer);
		$criteria->compare('Codes_Gruppe',$this->Codes_Gruppe);
		$criteria->compare('Code',$this->Code);
		$criteria->compare('Verbindungsart',$this->Verbindungsart,true);
		$criteria->compare('Datum',$this->Datum,true);
		$criteria->compare('Anzahl1',$this->Anzahl1);
		$criteria->compare('Anzahl_2',$this->Anzahl_2);
		$criteria->compare('Anzahl_3',$this->Anzahl_3);
		$criteria->compare('Anzahl_4',$this->Anzahl_4);
		$criteria->compare('Betrag',$this->Betrag);
		$criteria->compare('VerbindungsTabelle',$this->VerbindungsTabelle,true);
		$criteria->compare('VerbindungsKey',$this->VerbindungsKey,true);
		$criteria->compare('Bitmap_Verbindung',$this->Bitmap_Verbindung,true);
		$criteria->compare('Verbindungsfilekey',$this->Verbindungsfilekey,true);
		$criteria->compare('Bezeichnung',$this->Bezeichnung,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}